package com.ts.login.controller;


import com.ts.common.dto.Sms;
import com.ts.common.entity.ResponseResult;
import com.ts.login.dto.LoginDto;
import com.ts.login.dto.PhonePayload;
import com.ts.login.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping ("/login")
@Slf4j
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/phone")
    public ResponseResult login(@RequestBody LoginDto<PhonePayload> payload) {
        String token = loginService.loginByPhone(payload);
        return ResponseResult.success(token);
    }
    @PostMapping("/codeSend")
    public ResponseResult codeSend(@RequestBody Sms sms) {
        loginService.codeSend(sms);
        return ResponseResult.success();
    }
}
